package com.talos.ums.dal.mysql.usercustomer;

import com.talos.framework.common.pojo.PageResult;
import com.talos.framework.mybatis.core.mapper.BaseMapperX;
import com.talos.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.talos.ums.controller.admin.usercustomer.vo.UmsUserCustomerPageReqVO;
import com.talos.ums.dal.dataobject.usercustomer.UmsUserCustomerDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 账号关联客户表 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface UmsUserCustomerMapper extends BaseMapperX<UmsUserCustomerDO> {

    default PageResult<UmsUserCustomerDO> selectPage(UmsUserCustomerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UmsUserCustomerDO>()
                .eqIfPresent(UmsUserCustomerDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UmsUserCustomerDO::getCompanyId, reqVO.getCompanyId())
                .eqIfPresent(UmsUserCustomerDO::getCompanyCode, reqVO.getCompanyCode())
                .likeIfPresent(UmsUserCustomerDO::getCompanyName, reqVO.getCompanyName())
                .eqIfPresent(UmsUserCustomerDO::getCustomerId, reqVO.getCustomerId())
                .eqIfPresent(UmsUserCustomerDO::getCustomerCode, reqVO.getCustomerCode())
                .likeIfPresent(UmsUserCustomerDO::getCustomerName, reqVO.getCustomerName())
                .betweenIfPresent(UmsUserCustomerDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UmsUserCustomerDO::getCreatorId, reqVO.getCreatorId())
                .eqIfPresent(UmsUserCustomerDO::getCreatorCode, reqVO.getCreatorCode())
                .likeIfPresent(UmsUserCustomerDO::getCreatorName, reqVO.getCreatorName())
                .betweenIfPresent(UmsUserCustomerDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(UmsUserCustomerDO::getModifierId, reqVO.getModifierId())
                .eqIfPresent(UmsUserCustomerDO::getModifierCode, reqVO.getModifierCode())
                .likeIfPresent(UmsUserCustomerDO::getModifierName, reqVO.getModifierName())
                .eqIfPresent(UmsUserCustomerDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(UmsUserCustomerDO::getId));
    }

}
